//
//  TuijianAppViewController.m
//  ShaQueVideo
//
//  Created by are on 13-6-7.
//  Copyright (c) 2013年 科悦信达. All rights reserved.
//

#import "TuijianAppViewController.h"

@interface TuijianAppViewController ()

@end

@implementation TuijianAppViewController
#define MobiSage_Table_Recommend_Tag 1001
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (UIViewController *)viewControllerForPresentingModalView {

    return self;
}


-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

-(void)viewDidUnload{
    [super viewDidUnload];
    self.recommendView = nil;
}

 
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self showBackBtn];
    if (UIUserInterfaceIdiomPad == [UIDevice currentDevice].userInterfaceIdiom) {

        self.recommendView = [[MSRecommendContentView alloc] initWithdelegate:self width:700.0f adCount:22];
    }else {
        self.recommendView = [[MSRecommendContentView alloc] initWithdelegate:self width:300.0f adCount:22];
    }
    
    self.recommendView.tag = MobiSage_Table_Recommend_Tag;
    self.title = @"应用推荐";
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    [self.tableView release];

    // Do any additional setup after loading the view from its nib.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{


    // Return the number of rows in the section.
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (![cell isKindOfClass:[UITableViewCell class]]) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    // Configure the cell...


        cell.textLabel.text = nil;
        UIView *subView = [cell.contentView viewWithTag:MobiSage_Table_Recommend_Tag];
        if (subView != self.recommendView) {

            [cell.contentView addSubview:self.recommendView];
        }
    
    return cell;
}

- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

        if (UIUserInterfaceIdiomPad == [UIDevice currentDevice].userInterfaceIdiom) {

            return 157 * 22 *(700.0/640.0);

        }else {

            return 157 * 22*(300.0/640.0);
        }
    
}
- (void)MobiSageWillOpenRecommendModalView
/**
 *  应用推荐界面打开失败时调用
 */
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"网络不给力啊！！！" message:nil
                                                   delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
    [alert release];
}
- (void)MobiSageFailToOpenRecommendModalView
/**
 *  应用推荐界面关闭时调用
 */
{
    
}
- (void)MobiSageDidCloseRecommendModalView
{
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
